package com.oreilly.ez.entity;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@Entity
@Table(name = "walle_card")
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class WalleCard {

    @Id
    @GeneratedValue
    private Integer sid;
    private String scode;
    private String note;


    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    private Date udate;

//    @NotBlank(message = "tags不能为空")
    private String tags;

    @NotBlank(message = "标题不能为空")
    private String title;


    //简介
    private String summary;

    @JsonIgnore
    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "walle_tag_card_rel",
            joinColumns = @JoinColumn(name = "card_id"),
            inverseJoinColumns = @JoinColumn(name = "tag_id"))
    private List<WalleTag> tagList = new ArrayList<>();



//    @OneToMany(mappedBy = "walleCard")
//    @OrderBy("udate desc")
//    private List<WalleItem> itemList = new ArrayList<>();
}
